Add save_every_iter option#173
Open
klchen0112 wants to merge 3 commits into
Open
Conversation
rikonaka
suggested changes
Dec 14, 2023
rikonaka
left a comment
Contributor
There was a problem hiding this comment.
There seems to be a logical problem with some of the code ❤️
| return inputs | ||
|
|
||
| @staticmethod | ||
| def _save_adv_examples( |
Contributor
There was a problem hiding this comment.
Perhaps adding a type constraint or default parameters value for each parameter here would help other maintainers have a clear definition of parameter types.
| save_dict = { | ||
| "adv_inputs": adv_input_list_cat, | ||
| "labels": label_list_cat, | ||
| } # nopep8 |
Contributor
There was a problem hiding this comment.
Here # nopep8 can be removed.
|
|
||
| save_dict["save_type"] = save_type | ||
| torch.save(save_dict, save_path) | ||
| if save_path is not None and save_every_iter: |
Contributor
There was a problem hiding this comment.
The input parameters of these two self._save_adv_examples functions seem to be the same, so why are two placed here?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type and Checklist
What kind of change does this PR introduce?
When saving a large number of samples, saving each batch repeatedly will consume a lot of time.
I added an option to control whether generated samples are saved every epoch.
model.supported_modewhether the attack supports targeted mode.